Repository navigation
fix(parsers): inline directive JSON into bundle to stop srv-qa boot crash - #3042
Closed
jung-thomas wants to merge 1 commit into
Closed
jung-thomas wants to merge 1 commit into
jung-thomas wants to merge 1 commit into
Conversation
…rash tutorials-srv-qa crashed on start with MODULE_NOT_FOUND './icon-allowlist.json' (required by srv/lib/parsers.bundle.mjs), failing the MTA deploy. Root cause: commit 2adeeb3 switched ui.ts's icon-allowlist.json load from a static `import ... with { type: 'json' }` to a runtime createRequire(). esbuild bundles static JSON imports but leaves runtime requires external, so the bundled parsers.bundle.mjs referenced a sibling file that is never copied into gen/srv-qa/srv/lib/. reference-links.ts had the same latent pattern for api-libs.json. Fix: use static default imports (resolveJsonModule is on) so esbuild inlines both JSON files into the bundle — no external file to ship. Verified: rebuilt bundle has no residual require() of either JSON; the icon-allowlist values are present inline; directive unit tests pass (19/19).
Contributor
Author
|
Superseded by 81d6757 (already merged to DEV) which applies the identical static-JSON-import fix to both ui.ts and reference-links.ts. Closing as redundant. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A DEV deploy failed at
cf deploy:tutorials-srv-qacrashes on start, exhausting all 3 MTA retries. App log:Root cause
Commit
2adeeb33cswitchedscripts/parsers/directives/ui.tsfrom a staticimport iconAllowlist from './icon-allowlist.json' with { type: 'json' }to a runtimecreateRequire(import.meta.url)('./icon-allowlist.json').esbuild inlines static JSON imports into
parsers.bundle.mjsbut leaves runtime requires external. The externalizedrequire('./icon-allowlist.json')resolves relative togen/srv-qa/srv/lib/, where the JSON is never copied →MODULE_NOT_FOUND→ boot crash → deploy fail.reference-links.tshad the same latent pattern forapi-libs.json(a second time bomb in the same bundle).Fix
Use static default imports for both JSON files (
resolveJsonModule: trueis already set), so esbuild inlines them into the bundle — nothing external to ship.Verification
parsers.bundle.mjs:grepfinds no residualrequire('./icon-allowlist.json')orrequire('./api-libs.json').icon-allowlist.jsonvalues are present inline in the bundle.vitest run scripts/parsers/directives).Source-only change (2
.tsfiles); the bundle is gitignored and rebuilt at deploy time.🤖 Generated with Claude Code